package com.dwxt.cdms.controller;

import com.dwxt.cdms.base.Page;
import com.dwxt.cdms.service.OuFuService;
import com.dwxt.common.base.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;

@RestController
@RequestMapping("/cdms/oufu")
public class OuFuController {

    @Autowired
    private OuFuService ouFuService;

    /**
     * 接收欧浮设备数据
     * @param request
     * @return
     * @throws ParseException
     */
    @RequestMapping("/receiveData")
    public BaseResult receiveData(HttpServletRequest request) throws ParseException {
        return ouFuService.receiveData(request);
    }

    /**
     * 接收欧浮设备数据（中台）
     * @param request
     * @return
     * @throws ParseException
     */
    @RequestMapping("/receiveDataZT")
    public BaseResult receiveDataZT(HttpServletRequest request) throws ParseException {
        return ouFuService.receiveDataZT(request);
    }

    /**
     * 按用户分组查询最新数据并分页
     * @param page
     * @param name
     * @param type
     * @return
     */
    @RequestMapping("/pageGroup")
    public BaseResult pageGroup(Page page, String name ,String type,String category){
        return ouFuService.pageGroup(page,name,type,category);
    }

    /**
     * 数据详情（除睡眠）分页
     * @param page
     * @param customerId
     * @param type
     * @return
     */
    @RequestMapping("/page")
    public BaseResult page(Page page,Integer customerId,String type,String category){
        return ouFuService.page(page,customerId,type,category);
    }

    /**
     * 睡眠详情单独分页
     * @param page
     * @param customerId
     * @return
     */
    @RequestMapping("/pageSleep")
    public BaseResult pageSleep(Page page,Integer customerId){
        return ouFuService.pageSleep(page,customerId);
    }

    /**
     * @Description: TV获取单个用户欧浮曲线数据
     * @param customerId:客户id
     * @param scope:时间范围
     * @param type:类型
     * @return com.dwxt.common.base.BaseResult
     * @author chendq
     * @date 2021/8/19
     */
    @RequestMapping("/selectCustomerOufu")
    public BaseResult selectCustomerOufu(@RequestParam(required = true) String customerId,
                                         @RequestParam(required = true,defaultValue = "1")Integer scope,
                                         @RequestParam(required = true)String type){
        return ouFuService.selectCustomerOufuData(customerId,scope,type);
    }



}
